import ActionTypes from '../config/ActionTypes';
import Session from '../utils/SessionUtils';
import {AsyncStorage}from 'react-native'

const initState = {
	isSuccess: false,
	contacts: [],
};

const contactReducer = (state = initState, action) => {
	switch (action.type) {
		case ActionTypes.CONTACT + ActionTypes.FETCH_LOADING_SUFFIX:
			{
				return {
					...state,
					isSuccess: false,
				};
			}
			break;
		case ActionTypes.CONTACT + ActionTypes.FETCH_SUCCESS_SUFFIX:
			{            
				return {
					...state,
					isSuccess: true,
					contacts: action.items,
				};
			}
			break;
		case ActionTypes.CONTACT + ActionTypes.FETCH_ERROR_SUFFIX:
			{
				return {
					...state,
					isSuccess: false,
				};
			}
			break;
		default:
			{
				return state;
			}
			break;
	}
};


export default contactReducer;
